let $b={
    //get请求
    get(url,obj,callback){
        let xhr = new XMLHttpRequest();
        let str=Object.keys(obj).map(k=>{
            return k+"="+obj[k]
        }).join("&")
        xhr.open('GET',url+(str?"?"+str:""));
        xhr.send()
        xhr.onreadystatechange = function(){
            if(xhr.readyState===4){
                if(xhr.status===200) {
                    callback(JSON.parse(xhr.response))
                }
            }
        }
    },
    //post请求
    post(url,obj,callback){
        let xhr = new XMLHttpRequest();
        xhr.open('POST',url);
        xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        let str=Object.keys(obj).map(k=>{
            return k+"="+ obj[k]
        }).join("&")
        xhr.send(str)
        xhr.onreadystatechange = function(){
            if(xhr.readyState===4){
                if(xhr.status===200) {
                    callback(JSON.parse(xhr.response))
                }
            }
        }
    }
}